<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增服务分类')" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-serinfotype-add">
            <div class="form-group">    
                <label class="col-sm-3 control-label">服务名称：</label>
                <div class="col-sm-8">
                    <input name="serviceName" class="form-control" type="text">
                </div>
            </div>
           <!-- <div class="form-group">
                <label class="col-sm-3 control-label">是否热门服务：</label>
                <div class="col-sm-8">
                <select name="isHot" class="form-control m-b" required>
                    <option value="">请选择</option>
                    <option value="0">是</option>
                    <option value="1">否</option>
                </select>
                </div>
            </div>-->
            <div class="form-group">
                <label class="col-sm-3 control-label">分类级别：</label>
                <div class="col-sm-8">
                <select onchange="serLevel()" id="level" name="level" class="form-control m-b" required>
                    <option value="">请选择</option>
                    <option value="0">一级分类</option>
                    <option value="1">二级分类</option>
                </select>
                </div>
            </div>
            <div class="form-group" id="parentLevel">
                <label class="col-sm-3 control-label">上级分类名称：</label>
                <div class="col-sm-8">
                    <input id="parentServiceName" name="parentServiceName" class="form-control" type="text" onclick="selectUsersToParent()">
                    <input id="fid" name="fid" class="form-control" type="hidden">
                   <!-- <p id="fid"></p>-->
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var prefix = ctx + "lm/serinfotype"
        $("#parentLevel").hide();
        $("#form-serinfotype-add").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                var data = $("#form-serinfotype-add").serializeArray();
                /*data.push({"name": "fid", "value": $("#fid").val()});*/
                $.operate.save(prefix + "/add", data);
            }
        }

        function selectUsersToParent(){
            $.modal.open("选择上级分类", prefix + "/parent");
        }

        function serLevel(){
            var level = $("#level ").val();
           debugger;
           if(level == '0'){
             $("#parentLevel").hide();
           }
            if(level == '1'){
                $("#parentLevel").show();
            }
        }
    </script>
</body>
</html>